#include "main.h"

/*

Actual Program

**********************/

using namespace std;

void draw(){renderManager->update();}
void idle(){renderManager->update();}
void reDrawScreen(int w, int h){renderManager->reDrawScreen(renderManager->screenX, renderManager->screenY);}

void mouseButton(int button,int state,int x, int y){inputManager->pressedMouse(button,state,x,y);}
void dragMotion(int x, int y){inputManager->dragMouse(x,y);}
void mouseMotion(int x, int y){inputManager->moveMouse(x,y);}

void normalKey(unsigned char key, int x, int y){inputManager->normalKeyDown(key,x,y);}
void specialKey(int key, int x, int y){inputManager->specialKeyDown(key,x,y);}
void keyUp(unsigned char key,int x,int y){inputManager->keyUp(key,x,y);}
void specialKeyUp (int key,int x, int y){inputManager->specialKeyUp(key,x,y);}



int main(int argc, char** argv)
{
    //set instance, since we already created our Renderer...
    renderManager=Renderer::getInstance();
    inputManager=Input::getInstance();

    renderManager->loadPreferences();
    //renderManager->initWindow(renderManager->screenX,renderManager->screenY,"Moviesandbox 2");
    renderManager->initWindow(renderManager->windowX,renderManager->windowY,"Moviesandbox 2");


    //window stuff
	glutIdleFunc(idle);
    glutDisplayFunc(draw);
	glutReshapeFunc(reDrawScreen);

    //Mouse
  	glutMouseFunc(mouseButton);
	glutPassiveMotionFunc(mouseMotion);
	glutMotionFunc(dragMotion);

    //Keyboard
	glutKeyboardFunc(normalKey);
	glutSpecialFunc(specialKey);
    glutKeyboardUpFunc(keyUp);
    glutSpecialUpFunc(specialKeyUp);

    //run program
    renderManager->setup();

    glutMainLoop();

    delete(renderManager);

    return 0;
}

// load the named file and dump its structure to STDOUT

